We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.
Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)
Here's a test case: $ cat test.asm %macro macro 0 %warning %00 %endmacro label: macro %ifdef LABELALONE label: %endif jmp label $ nasm -v NASM version 2.16rc0 compiled on Jul 12 2022 $ nasm test.asm test.asm:5: warning: [-w+user] test.asm:2: ... from macro `macro' defined here $ oldnasm -v NASM version 2.14.03rc2 compiled on Aug 31 2019 $ oldnasm test.asm test.asm:5: warning: (macro:1) label [-w+user] test.asm:2: ... from macro `macro' defined here [-w+user] test.asm:9: error: symbol `label' undefined $ oldnasm test.asm -DLABELALONE test.asm:5: warning: (macro:1) label [-w+user] test.asm:2: ... from macro `macro' defined here [-w+user] $ The nasm executable is a build of the revision specified in my comment in https://github.com/netwide-assembler/nasm/pull/25#issuecomment-1186217590 with the patch of that PR applied.
Found the bug and the fix, the following patch includes both the fix and a small debugging helper I used to diagnose the error (commented out). ~/proj/nasmpat$ git diff diff --git a/asm/preproc.c b/asm/preproc.c index 0ff2b518..3c147f1e 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -7285,9 +7285,11 @@ static Token *pp_tokline(void) if (mmac) { const Token *t; list_for_each(t, tline) { - if (t->type == TOKEN_PREPROC_ID && + if (t->type == TOKEN_MMACRO_PARAM && !memcmp(t->text.a, "%00", 4)) mmac->capture_label = true; + if (0) printf("t->type=%u t->text.a=%s TOKEN_PREPROC_ID=%u\n", + t->type, t->text.a, TOKEN_PREPROC_ID); } } } else if (istk->conds && !emitting(istk->conds->state)) { This is the relevant output of the printf before applying the fix: $ ~/proj/nasmpat/nasm test.asm ... t->type=294 t->text.a=%warning TOKEN_PREPROC_ID=294 t->type=32 t->text.a= TOKEN_PREPROC_ID=294 t->type=295 t->text.a=%00 TOKEN_PREPROC_ID=294 test.asm:5: warning: [-w+user] test.asm:2: ... from macro `macro' defined here The code in question is at https://github.com/netwide-assembler/nasm/blob/3aebb20f123033dcd767f0abc46b18cbefed8091/asm/preproc.c#L7291 The token type enum is at https://github.com/netwide-assembler/nasm/blob/3aebb20f123033dcd767f0abc46b18cbefed8091/include/nasm.h#L250
Confirmed, and your fix checked in. Thank you!!